<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2023/12/31
 * Time: 6:47
 */
namespace app\modules\show\controllers;

use app\common\controllers\WebController;
use app\common\enum\SetUrlCrawler_statusEnum;
use app\common\service\GptCrawler;
use app\models\SetUrlCrawler;
use Yii;
use yii\helpers\Json;

class IndexController extends WebController
{
    public $debug = false;//调试接口
    public function actionIndex(){
        $url = urldecode(Yii::$app->request->post("url"));
        if(empty($url)){
            $url = urldecode(Yii::$app->request->get("url"));
        }
        $obj = new GptCrawler();
        $file_path = $obj->getFileDir($url);
        $name = $obj->getName($url);
        $content = file_get_contents($file_path."/{$name}.json");
        $arr_json = Json::decode($content,true);

        return $this->render("index",[
            'arr_json' => $arr_json
        ]);
    }
}